package com.example.project.Service.Impl;

import com.example.project.Entity.Bill;
import com.example.project.Mapper.BillMapper;
import com.example.project.Service.BillService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service("BillService")
public class BillServiceImpl implements BillService {
    @Autowired
    BillMapper billMapper;
    @Override
    public List<Bill> QueryByConditions(Bill bill ,int pageNum,int pageSize)
    {
        PageHelper.startPage(pageNum,pageSize);
        Page<Bill> bills=(Page<Bill>)billMapper.QueryByConditions(bill);
     return bills.getResult();
    }
    @Override
    public int addBill(Bill bill){
        return billMapper.insertBill(bill);
    }

    @Override
    public int deleteBill(int id){
        return billMapper.deleteBillById(id);
    }

    @Override
    public int updateBill(Bill bill){
        return billMapper.updateBill(bill);
    }
    @Override
    public Bill queryById(Bill bill){
        return billMapper.queryById(bill.getId());
    }

    public List<Bill> QueryByAll(){
        return billMapper.queryByAll();
    }

    public Page<Bill> queryByPage()
    {
        PageHelper.startPage(1,5);
        Page<Bill> bills=(Page<Bill>) billMapper.queryByAll();
        System.out.println(bills);
        return bills;
    }
}
